package decimal;

import java.math.BigDecimal;

public class Test04 {
    public static void main(String[] args) {
        double[] arr = {0.1, 0.2, 2.1, 3.2, 5.56, 7.21};
        BigDecimal sum = new BigDecimal(0);

        for (int i = 0; i < arr.length; i++) {
            BigDecimal res = new BigDecimal(arr[i]);
            sum = sum.add(res);
        }

        BigDecimal decimal = new BigDecimal(arr.length);
        BigDecimal divide = sum.divide(decimal, 3, BigDecimal.ROUND_HALF_UP);
        System.out.println(divide);
    }
}
